xm: pass-through: sort the output of xm pci-list
authorKeir Fraser <keir.fraser@citrix.com>
Thu, 4 Jun 2009 09:43:44 +0000 (10:43 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Thu, 4 Jun 2009 09:43:44 +0000 (10:43 +0100)
Other than being arguably more human readable,
this patch reconciles the output differences between
using Xen API and xmlrpc to manipulate domains.

Signed-off-by: Simon Horman <horms@verge.net.au>
tools/python/xen/util/pci.py
tools/python/xen/xm/main.py

index 2af8b18c5a4a8691ea6ed369e7f6e2584e75fecc..be7ab7108e14c2a6306863fa92c643514afa6b66 100644 (file)
@@ -114,6 +114,10 @@ PAGE_MASK=~(PAGE_SIZE - 1)
 def PCI_DEVFN(slot, func):
     return ((((slot) & 0x1f) << 3) | ((func) & 0x07))
 
+def PCI_BDF(domain, bus, slot, func):
+    return (((domain & 0xffff) << 16) | ((bus & 0xff) << 8) |
+            PCI_DEVFN(slot, func))
+
 def serialise_pci_opts(opts):
     return reduce(lambda x, y: x+','+y, map(lambda (x, y): x+'='+y, opts))
 
index 185c30402854f547459019f4797a4ff050f7a0de..bea552452e2ed0a1b3ee9de446b53bc0441fc0ca 100644 (file)
@@ -2205,6 +2205,9 @@ def xm_pci_list(args):
     if len(devs) == 0:
         return
 
+    devs.sort(None, lambda x: x['vslot'] << 32 | PCI_BDF(x['domain'], x['bus'],
+                                                         x['slot'], x['func']))
+
     has_vslot = False
     for x in devs:
         if x['vslot'] == AUTO_PHP_SLOT: